/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Huu Vinh
 */
@Entity
@Table(name = "Accounts", catalog = "Radio_Cabs", schema = "dbo", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"Uid"})})
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Accounts.findAll", query = "SELECT a FROM Accounts a"),
    @NamedQuery(name = "Accounts.findByAccId", query = "SELECT a FROM Accounts a WHERE a.accId = :accId"),
    @NamedQuery(name = "Accounts.findByUid", query = "SELECT a FROM Accounts a WHERE a.uid = :uid"),
    @NamedQuery(name = "Accounts.findByPwd", query = "SELECT a FROM Accounts a WHERE a.pwd = :pwd"),
    @NamedQuery(name = "Accounts.findByJoinDate", query = "SELECT a FROM Accounts a WHERE a.joinDate = :joinDate"),
    @NamedQuery(name = "Accounts.findByStartDate", query = "SELECT a FROM Accounts a WHERE a.startDate = :startDate"),
    @NamedQuery(name = "Accounts.findByEndDate", query = "SELECT a FROM Accounts a WHERE a.endDate = :endDate"),
    @NamedQuery(name = "Accounts.findByStatus", query = "SELECT a FROM Accounts a WHERE a.status = :status")})
public class Accounts implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Basic(optional = false)
    @Column(name = "AccId", nullable = false)
    private Integer accId;
    @Basic(optional = false)
    @Column(name = "Uid", nullable = false, length = 50)
    private String uid;
    @Basic(optional = false)
    @Column(name = "Pwd", nullable = false, length = 50)
    private String pwd;
    @Basic(optional = false)
    @Column(name = "JoinDate", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date joinDate;
    @Column(name = "StartDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startDate;
    @Column(name = "EndDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endDate;
    @Basic(optional = false)
    @Column(name = "Status", nullable = false)
    private boolean status;
    @JoinColumn(name = "TypeId", referencedColumnName = "TypeId")
    @ManyToOne(fetch = FetchType.EAGER)
    private AccountsType typeId;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "accounts", fetch = FetchType.EAGER)
    private Advertise advertise;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "accId", fetch = FetchType.EAGER)
    private List<Order1> order1List;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "accounts", fetch = FetchType.EAGER)
    private Driver driver;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "accounts", fetch = FetchType.EAGER)
    private AccountDetails accountDetails;
    @OneToMany(mappedBy = "accountId", fetch = FetchType.EAGER)
    private List<Feedback> feedbackList;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "accounts", fetch = FetchType.EAGER)
    private Company company;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "accounts", fetch = FetchType.EAGER)
    private List<PaymentDetails> paymentDetailsList;

    public Accounts() {
    }

    public Accounts(Integer accId) {
        this.accId = accId;
    }

    public Accounts(Integer accId, String uid, String pwd, Date joinDate, boolean status) {
        this.accId = accId;
        this.uid = uid;
        this.pwd = pwd;
        this.joinDate = joinDate;
        this.status = status;
    }

    public Integer getAccId() {
        return accId;
    }

    public void setAccId(Integer accId) {
        this.accId = accId;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public Date getJoinDate() {
        return joinDate;
    }

    public void setJoinDate(Date joinDate) {
        this.joinDate = joinDate;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public AccountsType getTypeId() {
        return typeId;
    }

    public void setTypeId(AccountsType typeId) {
        this.typeId = typeId;
    }

    public Advertise getAdvertise() {
        return advertise;
    }

    public void setAdvertise(Advertise advertise) {
        this.advertise = advertise;
    }

    @XmlTransient
    public List<Order1> getOrder1List() {
        return order1List;
    }

    public void setOrder1List(List<Order1> order1List) {
        this.order1List = order1List;
    }

    public Driver getDriver() {
        return driver;
    }

    public void setDriver(Driver driver) {
        this.driver = driver;
    }

    public AccountDetails getAccountDetails() {
        return accountDetails;
    }

    public void setAccountDetails(AccountDetails accountDetails) {
        this.accountDetails = accountDetails;
    }

    @XmlTransient
    public List<Feedback> getFeedbackList() {
        return feedbackList;
    }

    public void setFeedbackList(List<Feedback> feedbackList) {
        this.feedbackList = feedbackList;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    @XmlTransient
    public List<PaymentDetails> getPaymentDetailsList() {
        return paymentDetailsList;
    }

    public void setPaymentDetailsList(List<PaymentDetails> paymentDetailsList) {
        this.paymentDetailsList = paymentDetailsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accId != null ? accId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Accounts)) {
            return false;
        }
        Accounts other = (Accounts) object;
        if ((this.accId == null && other.accId != null) || (this.accId != null && !this.accId.equals(other.accId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Accounts[ accId=" + accId + " ]";
    }
    
}
